import 'package:flutter/material.dart';
import 'TestLoadingDialog.dart';
import 'TestMessageDialog.dart';

class TestDialog extends StatefulWidget {
  @override
  _TestDialogState createState() => _TestDialogState();
}

class _TestDialogState extends State<TestDialog> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('对话框测试'),
      ),
      body: ListView(
        children: <Widget>[
          ListTile(
            leading: Icon(Icons.list),
            title: Text("自定义加载对话框"),
            onTap: () {
              showDialog<Null>(
                context: context, //BuildContext对象
                barrierDismissible: false,
                builder: (BuildContext context) {
                  return new TestLoadingDialog(
                    //调用对话框
                    text: '正在获取详情...',
                  );
                },
              );
            },
          ),
          ListTile(
            leading: Icon(Icons.list),
            title: Text("自定义消息对话框"),
            onTap: () {
              showDialog<Null>(
                context: context, //BuildContext对象
                barrierDismissible: false,
                builder: (BuildContext context) {
                  return new TestMessageDialog(
                    //调用对话框
                    title: "关于我们",
                    message: '你好！这是关于我们的内容',
                    onCloseEvent: () {
                      Navigator.pop(context);
                    },
                  );
                },
              );
            },
          ),
        ],
      ),
    );
  }
}
